package com.wbxqy.car_management_system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wbxqy.car_management_system.entity.Department;
import com.wbxqy.car_management_system.entity.User;
import com.wbxqy.car_management_system.mapper.UserMapper;
import com.wbxqy.car_management_system.service.IDepartmentService;
import com.wbxqy.car_management_system.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author wbxqy
 * @since 2024-07-04
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {
    @Autowired
    IDepartmentService departmentService;

    @Override
    public User getByIdWithDepartment(Integer id) {
        final User user = this.getById(id);
        final Department department = departmentService.getById(user.getDepartmentIdWbxqy());
        user.setDepartment(department);
        return user;
    }
}
